home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue38 / Clinic / StpKey1U.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-07-07  |  1.2 KB  |  60 lines

  1. unit StpKey1U;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Edit1: TEdit;
  12.     Edit2: TEdit;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     Edit3: TEdit;
  17.     Edit4: TEdit;
  18.     Edit5: TEdit;
  19.     Edit6: TEdit;
  20.     Edit7: TEdit;
  21.     Edit8: TEdit;
  22.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  23.       Shift: TShiftState);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  38.   Shift: TShiftState);
  39. begin
  40.   { Check for Escape }
  41.   if (Key = vk_Escape) and (Shift = []) then
  42.   begin
  43.     Color := RGB(Random(256), Random(256), Random(256));
  44.     Key := 0
  45.   end;
  46.   { Check for Ctrl+S or Alt+S }
  47.   if (Key = Ord('S')) and ((Shift = [ssCtrl]) or (Shift = [ssAlt])) then
  48.   begin
  49.     if Shift = [ssCtrl] then
  50.       Application.Minimize
  51.     else
  52.       Caption := 'Alt+S was pressed at ' + TimeToStr(Time);
  53.     Key := 0
  54.   end
  55. end;
  56.  
  57. initialization
  58.   Randomize
  59. end. 
  60.